<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改设备材料合同附件单')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-fj-edit" th:object="${gcProjectSbclhtFj}">
            <input name="id" th:field="*{id}" type="hidden">
            <input name="gcProjectid" th:field="*{gcProjectid}" type="hidden">
            <input name="sbclhtId" th:field="*{sbclhtId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">项目编号：</label>
                <div class="col-sm-8">
                    <input name="orderNo" th:field="*{orderNo}" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">资料文件：</label>
                <div class="col-sm-8" style="margin-top: 8px;">
                	<input type="hidden" id="zlwj" th:value="*{zilwj}" />
                    <a href="#" target='_blank' id="zlwjlink" th:text="*{zilwj}">查看资料</a>
                </div>
            </div>
            <div class="form-group" th:if="${gcProjectSbclht.status} eq 0">
           		<label class="col-sm-3 control-label">更改资料文件：</label>
               	<div class="col-sm-8 fileinput fileinput-new" data-provides="fileinput">
                   <span class="btn btn-white btn-file">
                   	<span class="fileinput-new">选择文件</span>
                   	<span class="fileinput-exists">更改</span>
                   	<input type="file" name="zilwjfile" id="zilwjfile">
                   </span>
                   <span class="fileinput-filename"></span>
                   <a href="#" class="close fileinput-exists" data-dismiss="fileinput" style="float: none">&times;</a>
            	</div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button th:if="${gcProjectSbclht.status} eq 0" type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script th:src="@{/ruoyi/base64.min.js?v=20231208}"></script>
    <script th:inline="javascript">
        var prefix = ctx + "gcgl/sbclhtFj";
        $("#form-fj-edit").validate({
            focusCleanup: true
        });
        
        $(function() {
        	var zlwj = $("#zlwj").val();
//         	var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(zlwj));
        	var url = zlwj;
    		$("#zlwjlink").attr("href",url);
        });

        function submitHandler() {
            if ($.validate.form()) {
            	
            	var form = document.getElementById("form-fj-edit");
                var file = new FormData(form);
                $.ajax({
                    url: prefix+"/edit",
                    type: "POST",
                    processData:false,
                    contentType:false,
                    //重要部分，data的传的是整个表单，不用大括号包裹；不用自定义变量名
                    data:file,
                    success: function (date) {
                    	$.modal.close();
                    	refreshTab();
                    },
                    error: function (date) {
                    	$.modal.close();
                    	refreshTab();
                    }
                })
            	
                //$.operate.save(prefix + "/edit", $('#form-fj-edit').serialize());
            }
        }

    </script>
</body>
</html>